#ifndef FILE_se_Animation_HPP
#define FILE_se_Animation_HPP

#include <string>
#include <SFML/Graphics.hpp>
#include "../System.hpp"
#include "../Storage.hpp"



namespace se {
namespace Graphics {
	
class AnimatedSprite;

///////////////////////////////////////////////////////////////////////////////
/// \brief Stores an animation and update sprites.
/// 
/// This class stores the needed informations for displaying an animated
/// sprite. It is loaded from a file, or created with data given via the
/// constuctor's parameters. It can then be used to update a Sprite, trough
/// modifications of the Image and the SubRect setting, using the Sprite's
/// chronometer. For this reason, an animated sprite will behave strangely
/// when SetSubrect is used upon it. 
/// 
/// Ideally, it is used with a
/// DrawableDataPool, to make sure no animation is loaded twice. The ID
/// is then used to access it.
/// 
/// @see UpdateSprite(Sprite& sprite)
///////////////////////////////////////////////////////////////////////////////
class AnimationData {
	DISALLOW_COPY_AND_ASSIGN(AnimationData);
	//
	//Member Functions
	//
		public :
			AnimationData();
			AnimationData(ContentFile &c,uint32_t contentRef);
			AnimationData(uint16_t nFrames,uint16_t frameTime,uint32_t imageRef, ContentFile &c, const std::string s);
			
			bool GetDataIsLoaded();
			void LoadData();
			void UnloadData();
			
			const sf::Texture& GetSourceImage();
			sf::Rect<int> GetSubrectFromTime( Time_t t);
			Time_t GetLoopTime();//in milliseconds
			
			uint16_t GetFrame(Time_t t);
			~AnimationData();
			// The edition methods are not implemented.
		
		protected:
			sf::Rect<int> GetSubrectFromFrame(uint16_t frame);
		
	
	//
	//Attributes
	//
		public:
			std::string ID;
		protected :
			bool m_dataIsLoaded;
			ContentFile* m_dataContentFile;
			uint32_t m_dataRef;
			/// Image from which the subrects will be made.
			sf::Texture m_sourceImg;
			uint16_t m_nFrames;
			uint16_t m_frameTime;//in milliseconds, so max 65s.

};//</class AnimationData>


}//</namespace Graphics>
}//</namespace se>

#endif
